Break out common parts of vtpm tests into new vtpm_utils library.
authoremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Tue, 21 Mar 2006 10:49:29 +0000 (11:49 +0100)
committeremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Tue, 21 Mar 2006 10:49:29 +0000 (11:49 +0100)
Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/xm-test/tests/vtpm/01_vtpm-list_pos.py
tools/xm-test/tests/vtpm/02_vtpm-cat_pcrs.py
tools/xm-test/tests/vtpm/03_vtpm-susp_res.py
tools/xm-test/tests/vtpm/Makefile.am
tools/xm-test/tests/vtpm/vtpm_utils.py [new file with mode: 0644]

index 0aa45f1d37cdccf654c83d534f79630ad09181cc..f5c428e1cab2efbcc1d7231c0df0dd3386fe20b8 100644 (file)
@@ -8,17 +8,10 @@
 
 
 from XmTestLib import *
+from vtpm_utils import *
 import commands
 import os
 
-def vtpm_cleanup(domName):
-    # Since this is only a temporary domain I clean up the domain from the
-    # virtual TPM directory
-    os.system("/etc/xen/scripts/vtpm-delete %s" % domName)
-
-if ENABLE_HVM_SUPPORT:
-    SKIP("vtpm-list not supported for HVM domains")
-
 config = {"vtpm":"instance=1,backend=0"}
 domain = XmTestDomain(extraConfig=config)
 
index 18021380d8a0cd62674a26b71754b8f89660b256..ab948b827d767df4f91e3a82d7b2a30c56705fd7 100644 (file)
@@ -7,26 +7,11 @@
 #                check list of pcrs
 
 from XmTestLib import *
+from vtpm_utils import *
 import commands
 import os
 import os.path
 
-def vtpm_cleanup(domName):
-    # Since this is only a temporary domain I clean up the domain from the
-    # virtual TPM directory
-    os.system("/etc/xen/scripts/vtpm-delete %s" % domName)
-
-if ENABLE_HVM_SUPPORT:
-    SKIP("vtpm-list not supported for HVM domains")
-
-if os.path.exists("/dev/tpm0") == False:
-    SKIP("This machine has no hardware TPM; cannot run this test")
-
-output = commands.getoutput("ps aux | grep vtpm_manager | grep -v grep")
-if output == "":
-    SKIP("virtual TPM manager must be started to run this test")
-
-# vtpm manager has been detected
 config = {"vtpm":"instance=1,backend=0"}
 domain = XmTestDomain(extraConfig=config)
 
index f4f6191edbbb60b6fa4bbad2f5ea8cff053f4caf..793e4b2afc6e2808eaf3cb7594df77da273afef9 100644 (file)
@@ -8,26 +8,11 @@
 #                check list of pcrs again
 
 from XmTestLib import *
+from vtpm_utils import *
 import commands
 import os
 import os.path
 
-def vtpm_cleanup(domName):
-    # Since this is only a temporary domain I clean up the domain from the
-    # virtual TPM directory
-    os.system("/etc/xen/scripts/vtpm-delete %s" % domName)
-
-if ENABLE_HVM_SUPPORT:
-    SKIP("vtpm-list not supported for HVM domains")
-
-if os.path.exists("/dev/tpm0") == False:
-    SKIP("This machine has no hardware TPM; cannot run this test")
-
-output = commands.getoutput("ps aux | grep vtpm_manager | grep -v grep")
-if output == "":
-    SKIP("virtual TPM manager must be started to run this test")
-
-# vtpm manager has been detected
 config = {"vtpm":"instance=1,backend=0"}
 domain = XmTestDomain(extraConfig=config)
 
index 5ee4cfb071d5f8c5f93c627ee3ec839cff0d08ca..3e11292827782a87a3f6798f4a9369ce8acf3ec1 100644 (file)
@@ -1,4 +1,3 @@
-
 SUBDIRS =
 
 TESTS = 01_vtpm-list_pos.test \
@@ -7,8 +6,7 @@ TESTS = 01_vtpm-list_pos.test \
 
 XFAIL_TESTS =
 
-EXTRA_DIST = $(TESTS) $(XFAIL_TESTS)
-
+EXTRA_DIST = $(TESTS) $(XFAIL_TESTS) vtpm_utils.py
 TESTS_ENVIRONMENT=@TENV@
 
 %.test: %.py
diff --git a/tools/xm-test/tests/vtpm/vtpm_utils.py b/tools/xm-test/tests/vtpm/vtpm_utils.py
new file mode 100644 (file)
index 0000000..34e4afd
--- /dev/null
@@ -0,0 +1,19 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2006
+# Author: Stefan Berger <stefanb@us.ibm.com>
+
+from XmTestLib import *
+
+if ENABLE_HVM_SUPPORT:
+    SKIP("vtpm tests not supported for HVM domains")
+
+if not os.path.isfile("/dev/tpm0"):
+    SKIP("This machine has no hardware TPM; cannot run this test")
+
+status, output = traceCommand("ps aux | grep vtpm_manager | grep -v grep")
+if output == "":
+    FAIL("virtual TPM manager must be started to run this test")
+
+def vtpm_cleanup(domName):
+       traceCommand("/etc/xen/scripts/vtpm-delete %s" % domName)